package com.ly.service.impl;

import com.ly.dao.AccountDao;
import com.ly.entity.BankAccount;
import com.ly.service.DepositService;

import static com.ly.utils.IOUtil.getDoubleInput;

/**
 * Author: LiYao
 * CreateTime: 2025-03-11 21:09
 * Description:
 * Version: 1.0
 */
public class DepositServiceImpl implements DepositService {
    AccountDao accountDao = new AccountDao();

    @Override
    public void deposit(BankAccount account) {
        double amount = getDoubleInput("请输入存款金额：");
        if(amount>0){
            double newBalance = account.getBalance()+amount;
            accountDao.updateBalance(account,newBalance);
            System.out.println("存款成功！");
        }else {
            System.out.println("存款失败！存款金额必须大于零！");
        }

    }
}
